package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingResourceFeeServiceDao;
import com.java110.dto.housekeeping.HousekeepingResourceFeeDto;
import com.java110.intf.cart.IHousekeepingResourceFeeInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingResourceFeePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 物品费用管理内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingResourceFeeInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingResourceFeeInnerServiceSMO {

    @Autowired
    private IHousekeepingResourceFeeServiceDao housekeepingResourceFeeServiceDaoImpl;


    @Override
    public int saveHousekeepingResourceFee(@RequestBody HousekeepingResourceFeePo housekeepingResourceFeePo) {
        int saveFlag = 1;
        housekeepingResourceFeeServiceDaoImpl.saveHousekeepingResourceFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingResourceFeePo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingResourceFee(@RequestBody  HousekeepingResourceFeePo housekeepingResourceFeePo) {
        int saveFlag = 1;
         housekeepingResourceFeeServiceDaoImpl.updateHousekeepingResourceFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingResourceFeePo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingResourceFee(@RequestBody  HousekeepingResourceFeePo housekeepingResourceFeePo) {
        int saveFlag = 1;
        housekeepingResourceFeePo.setStatusCd("1");
        housekeepingResourceFeeServiceDaoImpl.updateHousekeepingResourceFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingResourceFeePo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingResourceFeeDto> queryHousekeepingResourceFees(@RequestBody  HousekeepingResourceFeeDto housekeepingResourceFeeDto) {

        //校验是否传了 分页信息

        int page = housekeepingResourceFeeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingResourceFeeDto.setPage((page - 1) * housekeepingResourceFeeDto.getRow());
        }

        List<HousekeepingResourceFeeDto> housekeepingResourceFees = BeanConvertUtil.covertBeanList(housekeepingResourceFeeServiceDaoImpl.getHousekeepingResourceFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingResourceFeeDto)), HousekeepingResourceFeeDto.class);

        return housekeepingResourceFees;
    }


    @Override
    public int queryHousekeepingResourceFeesCount(@RequestBody HousekeepingResourceFeeDto housekeepingResourceFeeDto) {
        return housekeepingResourceFeeServiceDaoImpl.queryHousekeepingResourceFeesCount(BeanConvertUtil.beanCovertMap(housekeepingResourceFeeDto));    }

    public IHousekeepingResourceFeeServiceDao getHousekeepingResourceFeeServiceDaoImpl() {
        return housekeepingResourceFeeServiceDaoImpl;
    }

    public void setHousekeepingResourceFeeServiceDaoImpl(IHousekeepingResourceFeeServiceDao housekeepingResourceFeeServiceDaoImpl) {
        this.housekeepingResourceFeeServiceDaoImpl = housekeepingResourceFeeServiceDaoImpl;
    }
}
